package com.shiminghui;

public class CopyArr {
    public static void main(String[] args) {
        int[] arr ={1,2,3,4,5,6,7,8,9};
        int[] arr2= copyArr(arr,2,5);
        for (int j : arr2) {
            System.out.print(j + " ");
        }

    }

    private static int[] copyArr(int[] arr, int begin,int end){
        int[] array = new int[end-begin];
        for (int i = begin,j=0; i < end; i++,j++) {
            array[j]=arr[i];
        }
        return array;
    }
}
